// createRouter:创建router实例对象
// createWebHistory：创建history模式的路由

import { createRouter, createWebHistory } from 'vue-router'
import bookInformation from '@/views/BookInformation/index.vue'
import Reader from '@/views/Reader/index.vue'
import Login from '@/views/Login/components/LoginForm.vue'
import Register from '@/views/Login/components/RegisterForm.vue'
import Retrieve from '@/views/Login/components/RetrieveForm.vue'
import Slidebox from '@/views/Login/components/Slider.vue'
import User from '@/views/Login/User.vue'
import Layout from '@/views/Layout/main.vue'
import Category from '@/views/Category/category.vue'
import SearchPage from '@/views/Search/search.vue'
import Home from '@/views/Home/Home.vue'
import Space from '@/views/Home/components/Space.vue'
import Setting from '@/views/Home/components/Setting.vue'
import WriterCenter from '@/views/Home/components/WriterCenter.vue'
import Messages from '@/views/Home/components/Message.vue'
import admin from '@/views/Home/components/admin.vue'
import NotFound from '@/views/Exception/NotFound.vue'
import Instruction from "@/views/Instruction/index.vue"

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    // path和component对应关系的位置
    routes:[
        {
            path:'/bookInformation/:id',
            name:'BookDetail',
            component:bookInformation
        },
        {
            path: '/reader/:id/:chapterID',
            component: Reader
        },
        {
            path:'/instruction',
            component:Instruction
        },
        {
            path:'/',
            component: Layout
        },
        {
            path:'/search/:input',
            component: SearchPage
        },
        {
            path:'/category/:select',
            component: Category
        },
       
        {
            path:'/user',
            component:User,
            children:[
                {
                    path:'',
                    component:Slidebox
                },
                {
                    path: 'login',
                    component: Login
                },
                {
                    path:'register',
                    component:Register
                },
                {
                    path:'Retrieve',
                    component:Retrieve
                }
            ]
        },
        {
            path: '/home',
            component: Home,
            children: [
                { 
                    path: 'space/:username',  
                    component: Space 
                },
                { 
                    path: 'setting/:username',  
                    component: Setting 
                },
                { 
                    path: 'message/:username', 
                    component: Messages 
                },
                { 
                    path: 'WriterCenter/:username', 
                    component: WriterCenter 
                },{
                    path:'admin/:username',
                    component:admin
                }
            ]
        },
        { 
            path: '/:pathMatch(.*)*',
             component: NotFound 
        },
    ]
})

export default router